package com.xl.generator.common;

import java.io.IOException;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;

/**
 * @author XGJ
 * @apiNote
 * @date 2022/10/6 21:55
 */
@Controller("BaseController")
public class BaseController {
    @Resource
    protected HttpServletResponse httpServletResponse;
    @Resource
    protected HttpServletRequest httpServletRequest;


    public void responseWriterJson(String str){
        this.httpServletResponse.setContentType("application/json;charset=utf-8");
        PrintWriter pw =null;
        try (PrintWriter writer = this.httpServletResponse.getWriter()) {
            writer.write(str);
            writer.flush();

        } catch (IOException e) {
            System.out.println("报错信息："+e.getMessage());
            System.out.println("报错原因："+e.getCause());

        }

    }


}
